package Form;

import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.Font;
import java.awt.Insets;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;

import Control.Job_Delete_Controller;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Job_DeleteForm extends JPanel{
	private JLabel lblDeleteJob;
	private JLabel lblJobIdto;
	private JTextField jobID;
	private JLabel lbltoChangeAvailability;
	private JButton btnConfirm;  
	Job_Delete_Controller control;
	
	private JFrame parser;
	
	public JFrame getParser() {
		return parser;
	}

	public void setParser(JFrame parser) {
		this.parser = parser;
	}

	public Job_DeleteForm() {
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{180, 0, 95, 0};
		gridBagLayout.rowHeights = new int[]{25, 0, 0, 0, 0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		GridBagConstraints gbc_lblDeleteJob = new GridBagConstraints();
		gbc_lblDeleteJob.insets = new Insets(0, 0, 5, 5);
		gbc_lblDeleteJob.gridx = 1;
		gbc_lblDeleteJob.gridy = 0;
		add(getLblDeleteJob(), gbc_lblDeleteJob);
		GridBagConstraints gbc_lblJobIdto = new GridBagConstraints();
		gbc_lblJobIdto.anchor = GridBagConstraints.EAST;
		gbc_lblJobIdto.insets = new Insets(0, 0, 5, 5);
		gbc_lblJobIdto.gridx = 0;
		gbc_lblJobIdto.gridy = 2;
		add(getLblJobIdto(), gbc_lblJobIdto);
		GridBagConstraints gbc_jobID = new GridBagConstraints();
		gbc_jobID.anchor = GridBagConstraints.EAST;
		gbc_jobID.insets = new Insets(0, 0, 5, 5);
		gbc_jobID.gridx = 1;
		gbc_jobID.gridy = 2;
		add(getJobID(), gbc_jobID);
		GridBagConstraints gbc_lbltoChangeAvailability = new GridBagConstraints();
		gbc_lbltoChangeAvailability.insets = new Insets(0, 0, 5, 5);
		gbc_lbltoChangeAvailability.gridx = 0;
		gbc_lbltoChangeAvailability.gridy = 3;
		add(getLbltoChangeAvailability(), gbc_lbltoChangeAvailability);
		GridBagConstraints gbc_btnConfirm = new GridBagConstraints();
		gbc_btnConfirm.insets = new Insets(0, 0, 0, 5);
		gbc_btnConfirm.gridx = 1;
		gbc_btnConfirm.gridy = 6;
		add(getBtnConfirm(), gbc_btnConfirm);
	}

	public JLabel getLblDeleteJob() {
		if (lblDeleteJob == null) {
			lblDeleteJob = new JLabel("Delete Job");
			lblDeleteJob.setFont(new Font("Tahoma", Font.PLAIN, 20));
		}
		return lblDeleteJob;
	}
	public JLabel getLblJobIdto() {
		if (lblJobIdto == null) {
			lblJobIdto = new JLabel("Job ID:");
			lblJobIdto.setFont(new Font("Tahoma", Font.PLAIN, 15));
		}
		return lblJobIdto;
	}
	public JTextField getJobID() {
		if (jobID == null) {
			jobID = new JTextField();
			jobID.setColumns(10);
		}
		return jobID;
	}
	public JLabel getLbltoChangeAvailability() {
		if (lbltoChangeAvailability == null) {
			lbltoChangeAvailability = new JLabel(" (To change availability to \"Unavailable\")");
		}
		return lbltoChangeAvailability;
	}
	public JButton getBtnConfirm() {
		if (btnConfirm == null) {
			btnConfirm = new JButton("Confirm");
			btnConfirm.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					control.deleteJob();
					JOptionPane.showMessageDialog(null, "Update Success");
				}
			});
			btnConfirm.setFont(new Font("Tahoma", Font.BOLD, 15));
		}
		return btnConfirm;
	}
}
